home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
dbread2.zip
/
DBREAD.DOC
< prev
next >
Wrap
Text File
|
1992-01-08
|
3KB
|
81 lines
This is some sample C code for openning and reading the structure of a
dBASE DBF file. If you find any bugs, please report them to HMAN on
this BBS. The code is commented but requires a familiarity with the C
programming language. This is provided free of charge for those curious
in dabbling with C in conjunction with dBASE databases.
One thing I noticed in the development of this code is that if you
delete a production dBASE IV MDX file and subsequently USE that database
and choose to Proceed when notified about the missing MDX, the first
byte in the database is updated to indicate that no production MDX file
should be present. However, the Production .MDX flags in the field
descriptor array are not updated. I have reported this as a bug but
don't know what will become of it. It is something that you should be
aware of if you are going to get heavily into .DBF manipulation.
These programs were written and compiled using Microsoft QuickC 2.5 but
should be easily modified for other C compilers.
To run the compiled program, type DBREAD followed by the name of the DBF
file to be read. If no extension is specified, a .DBF extension is
added to the specified file name.
DBREAD.COM is a very simple program that opens the specified file and
assumes it is a DBF file and attempts to list its structure. It does
not validate the file as truly being a DBF file and does not accept
wildcard file names. No attempt is made to read the fields list of
encrypted files as this information is also encrypted and un-readable.
Also, it does _not_ work with dBASE II files.
DBREAD2.COM is a slightly more complex and useful version of DBREAD. It
can handle wildcard file names and tries to verify that the file being
read is truly a dBASE database. I've included it separately because I
wanted DBREAD to be a simple example that shows the core elements of
reading a DBF file. Also, DBREAD2 ignores the field descriptor array's
indication of the presence of an MDX tag when the header says that there
is no associated MDX file. DBREAD2 can read dBASE II database and list
their structures as well.
If you specify wild cards in the command line argument:
1) every matching file will be evaluated to see if it a dBASE II or
III/IV database. Only those that pass a small set of tests will
have their structures listed.
2) if the matching file name has a DBF, DBK, DBB, CVT, CRP, or CAT
extension but does not pass the tests, a message will be displayed
on the screen.
3) if the file does _not_ have a any of the above extensions and does
not pass the tests, no message is displayed, the file is simply
ignored.
If you specify a single file name and it does not pass the tests, a
message will be displayed.
You may not appreciate how hard this was, but I've added the capability
to specify pretty much any valid filespec as input for DBREAD2. It
works pretty much like the DIR command when it comes to analyzing
wild-card specifications. You can say
DBREAD2 .
for all .DBF files in the current drive and directory or
DBREAD2 D:
for all the .DBF files in the current directory of D:
.. is recognized and honored as part of a path specification, but not by
itself, e.g.
DBREAD2 ..
will _not_ read the files in the parent directory, but
DBREAD ..\
will read them.
Enjoy!
Martin R. Leon
Borland Software Support